#include <stdio.h>
#include <unistd.h>

#include "ohos_init.h"
#include "cmsis_os2.h"

#include "hi_gpio.h"
#include "iot_gpio.h"
#include "hi_io.h"
#include "jx906.h"
static void First_Task(void)
{
    float temperature;
    while (1)
    {
        temperature = jx906_get();
        printf("temperature = %.2f\n", temperature);
        osDelay(100);
    }
}
static void MainEntry(void)
{
    //初始化
    JX906_init();
    osThreadAttr_t attr;
    attr.name = "First_Task";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = 1024 * 4;
    attr.priority = osPriorityNormal;

    if (osThreadNew(First_Task, NULL, &attr) == NULL)
    {
        printf("[MAIN_Example] Falied to create First_Task!\n");
    }
    else
    {
        printf("[MAIN_Example] Success to create First_Task!\n");
    }
}
APP_FEATURE_INIT(MainEntry);